home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
dfue
/
avmnfax
/
rexx
/
answerdata.avm
< prev
next >
Wrap
Text File
|
1995-03-09
|
10KB
|
408 lines
/* TITLE: avm:rexx/answerdata.avm */
/* we want results! Otherwise, we wouldn't get anything from RESULT */
options results
/* Need to make sure that stdtail.avm is also included */
signal on halt
signal on novalue
signal on syntax
signal on break_c
/* needed for some of the functions we use */
call addlib("rexxsupport.library", 0, -30, 0)
/* a higher than normal priority since calls are important to us :) */
call pragma('priority', 1)
/* ensure that commands are directed to the correct server */
parse arg servername .
address value servername
parse arg servername faxscript datascript distinctivering 'CID$' acidname '$' acidnumber '$'
call setclip(address() || 'FAXSCRIPT', faxscript)
call setclip(address() || 'DATASCRIPT', datascript)
call setclip(address() || 'CIDNAME', acidname)
call setclip(address() || 'CIDNUMBER', acidnumber)
startup:
mailbox = 'anonymous'
signal stddata
exit
/* TITLE: avm:rexx/simplestdtail.avm */
/* This is the standard tail */
exit
exit
mailboxDir: procedure
parse arg mailbox
return 'avm:' || mailbox || '/'
logFile: procedure
parse arg mailbox, magiccookie
return 'avm:' || mailbox || '/logs/' || magiccookie
voiceFile: procedure
parse arg mailbox, magiccookie
if (verify(magiccookie, '/:', 'M') = 0) then
return 'avm:' || mailbox || '/voices/' || magiccookie
else
return magiccookie
makeUniqueFile: procedure
if arg() ~= 0 then do
rc = "makeUniqueFile: bad args"
signal error
end
return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
convertToDate: procedure
if arg() ~= 1 then do
rc = "convertToDate: bad args"
signal error
end
parse arg timeInC
actualTime = (timeInC - (2922)*86400) // (86400)
actualDate = (timeInC - actualTime - 2922*86400) % 86400
return actualDate /* returning it in 'internal' format */
convertToTime: procedure
if arg() ~= 1 then do
rc = "convertToTime: bad args"
signal error
end
parse arg timeInC
actualTime = (timeInC - (2922)*86400) // (86400)
return actualTime
cTime: procedure
/* 2922 = 8*365 + 2 */
/* 86400 = 24*60*60 */
return (date('i')+2922)*86400 + time('s')
/* this returns a handle that you must use after initializing log. */
initLogEntry: procedure expose log.
if arg() ~= 0 then do
rc = "initLogEntry: bad args"
signal error
end
drop log.
log. = ''
acidname = getclip(address() || 'CIDNAME')
acidnumber = getclip(address() || 'CIDNUMBER')
/* 2922 = 8*365 + 2 */
/* 86400 = 24*60*60 */
log.time = (date('i')+2922)*86400 + time('s')
log.cidname = acidname
log.cidnumber = acidnumber
return
loadLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "loadLogEntry: bad args"
signal error
end
parse arg mailbox, handle
drop log.
log. = ''
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
opened = open(handle, logFile(mailbox, handle), 'r')
if opened then do
call showDebugger('Loading entry' logFile(mailbox, handle))
do while ~eof(handle)
line = readln(handle)
parse upper var line variable '=' value
log.variable = value
end
call close(handle)
end; else call showDebugger('Could not load' logFile(mailbox, handle))
return
/* pass a handle here */
saveLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "saveLogEntry: bad args"
signal error
end
parse arg mailbox, handle
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
opened = open(handle, logFile(mailbox, handle), 'w')
if opened then do
call showDebugger('Saving entry' logFile(mailbox, handle))
call writeln(handle, 'TYPE=' || log.type)
call writeln(handle, 'TIME=' || log.time)
call writeln(handle, 'LENGTH=' || log.length)
call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
call writeln(handle, 'CIDNAME=' || log.cidname)
call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
call writeln(handle, 'COMMENT=' || log.comment)
call writeln(handle, 'FILENAME=' || log.filename)
call writeln(handle, 'ALTFILENAME=' || log.altfilename)
call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
call writeln(handle, 'RETURNRETRY=' || log.returnretry)
call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
call close(handle)
address rexx 'broadcast' 'addtomailbox' mailbox handle
end; else call showDebugger('Could not save' logFile(mailbox, handle))
return
/* pass a handle here */
updateLogEntry: procedure expose log.
if arg() ~= 2 then do
rc = "updateLogEntry: bad args"
signal error
end
parse arg mailbox, handle
if ~exists(mailboxDir(mailbox)) then do
call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
return
end
if ~exists(logFile(mailbox, handle)) then do
call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
return
end
opened = open(handle, logFile(mailbox, handle), 'w')
if opened then do
call showDebugger('Updating entry' logFile(mailbox, handle))
call writeln(handle, 'TYPE=' || log.type)
call writeln(handle, 'TIME=' || log.time)
call writeln(handle, 'LENGTH=' || log.length)
call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
call writeln(handle, 'CIDNAME=' || log.cidname)
call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
call writeln(handle, 'COMMENT=' || log.comment)
call writeln(handle, 'FILENAME=' || log.filename)
call writeln(handle, 'ALTFILENAME=' || log.altfilename)
call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
call writeln(handle, 'RETURNRETRY=' || log.returnretry)
call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
call close(handle)
address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
end; else call showDebugger('Could not update' logFile(mailbox, handle))
return
showDebugger: procedure
if arg() ~= 1 then do
say "showDebugger: ERROR"
exit 20
end
parse arg debuggerInfo
firstLine = sourceline(1)
parse var firstLine '/*' 'TITLE:' title '*/'
if showlist('p', 'AVMLOGGER') then
address 'AVMLOGGER' 'add' title ':' debuggerInfo
else
say title ':' debuggerInfo
return
/*-----------------------------------------------------------------------*/
/* signal processing */
arexxerror:
error:
call showDebugger("Error" rc "at line" sigl)
exit 20
break_c:
halt:
call showDebugger("Halt/Break_C at line" sigl)
exit 20
novalue:
call showDebugger("No value at line" sigl)
exit 20
syntax:
call showDebugger("Syntax error" rc "at line" sigl)
exit 20
exit
/* this requires logfunctions.avm */
loadMailbox: procedure expose mailbox.
if arg() ~= 1 then do
rc = "loadMailbox: bad args"
signal error
end
mailbox. = ''
parse arg mailbox
handle = 'mailboxconfig'
opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'r')
if opened then do
do while ~eof(handle)
line = readln(handle)
parse upper var line variable '=' value
mailbox.variable = value
end
call close(handle)
end
return
/* pass a handle here */
saveMailbox: procedure expose mailbox.
if arg() ~= 1 then do
rc = "saveMailbox: bad args"
signal error
end
parse arg mailbox
handle = 'mailboxconfig'
opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'w')
if opened then do
call writeln(handle, 'PASSWORD=' || mailbox.password)
call writeln(handle, 'AUTOFAXFORWARDB=' || mailbox.autofaxforwardb)
call writeln(handle, 'AUTOFAXFORWARD=' || mailbox.autofaxforward)
call writeln(handle, 'AUTOFAXFORWARDSCRIPT=' || mailbox.autofaxforwardscript)
call writeln(handle, 'AUTOFORWARDB=' || mailbox.autoforwardb)
call writeln(handle, 'AUTOFORWARDONDEMAND=' || mailbox.autoforwardondemand)
call writeln(handle, 'AUTOFORWARD=' || mailbox.autoforward)
call writeln(handle, 'AUTOFORWARDSCRIPT=' || mailbox.autoforwardscript)
call writeln(handle, 'AUTOPAGEB=' || mailbox.autopageb)
call writeln(handle, 'AUTOPAGEONDEMAND=' || mailbox.autopageondemand)
call writeln(handle, 'AUTOPAGE=' || mailbox.autopage)
call writeln(handle, 'AUTOPAGESCRIPT=' || mailbox.autopagescript)
call writeln(handle, 'AUTOALERTB=' || mailbox.autoalertb)
call writeln(handle, 'AUTOALERTONDEMAND=' || mailbox.autoalertondemand)
call writeln(handle, 'AUTOALERTSCRIPT=' || mailbox.autoalertscript)
call close(handle)
end
return
stdabort:
exit
stdbusy:
exit
stderror:
exit
stdtimedout:
exit
stdfaxinstruct:
'playvoice' 'avm:voices/FaxStarting'
action = rc
select
when action = 0 then nop
when action = 1 then do; call checkifabort; end
when action = 4 then nop
when action = 5 then nop
when action = 8 then signal stdbusy
when action = 12 then signal stdabort
when action = 14 then nop
when action = 16 then nop
otherwise signal arexxerror
end
stdfax:
faxscript = getclip(address() || 'FAXSCRIPT')
if faxscript = '' then faxscript = 'handlefax'
if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
else address rexx faxscript address() 'anonymous'
exit
stddatainstruct:
'playvoice' 'avm:voices/DataStarting'
action = rc
select
when action = 0 then nop
when action = 1 then do; call checkifabort; end
when action = 4 then nop
when action = 5 then nop
when action = 8 then signal stdbusy
when action = 12 then signal stdabort
when action = 14 then nop
when action = 16 then nop
otherwise signal arexxerror
end
stddata:
datascript = getclip(address() || 'DATASCRIPT')
if datascript = '' then datascript = 'handledata'
if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
else address rexx datascript address()
exit
checkifabort:
'readnkeys' '1' '3'
action = rc
if action = 0 then value = result
select
when action = 0 then do; if value = '*' then signal stdabort; end
when action = 4 then nop
when action = 5 then nop
when action = 8 then signal stdbusy
when action = 10 then nop
when action = 12 then signal stdabort
when action = 14 then signal stderror
when action = 16 then signal stderror
otherwise signal arexxerror
end
return